//
//  LLT_UserInfo.m
//  CoderLLT
//
//  Created by 刘晓萌 on 15/12/28.
//  Copyright © 2015年 刘晓萌. All rights reserved.
//

#import "LLT_UserInfo.h"
#import <AVOSCloud/AVOSCloud.h>



@implementation LLT_UserInfo


//单例实现
+(instancetype)shareUserInfo{
static LLT_UserInfo *userInfo;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        userInfo  = [LLT_UserInfo new];
    });
    return userInfo;
}
//获取用户名
-(NSString *)getUserName{
    AVUser *user = [AVUser currentUser];
    return user.username;
}
//获取用户图片
-(UIImage *)getUserImage{
    
    return nil;
}
//保存用户头像
-(void)setUserHeadImage:(UIImage *)image{
    //文件的归档
  NSData *imageData = UIImagePNGRepresentation(image);
 [[AVUser currentUser] setObject:imageData forKey:@"userIcon"];
   [[AVUser currentUser] saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
       if (succeeded) {
           //NSLog(@"添加成功");
       }else{
           //NSLog(@"添加错误:%@",error.userInfo[@"error"]);
       }
   }];
    
}


@end

